package cn.linweijian.kafka.producerdemo.service.impl;

import cn.linweijian.kafka.producerdemo.dto.InsertTaskDto;
import cn.linweijian.kafka.producerdemo.dto.TaskDto;
import cn.linweijian.kafka.producerdemo.dto.UpdateTaskDto;
import cn.linweijian.kafka.producerdemo.service.TaskService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * <p>
 * Created by linweijian on 2018/6/4 14:20
 */
@Service
public class TaskServiceImpl implements TaskService {

    @Override
    public List<InsertTaskDto> insertTask(List<TaskDto> taskDtoList) {
        List<InsertTaskDto> insertTaskDtos = new ArrayList<>();
        for (TaskDto dto : taskDtoList) {
            InsertTaskDto insertTaskDto = new InsertTaskDto();
            insertTaskDto.setTask_id(dto.getTask_id());
            insertTaskDto.setAssignments(dto.getAssignments());
            insertTaskDto.setPriority(dto.getPriority());
            insertTaskDto.setProcess_instance_form(dto.getProcess_instance_form());
            insertTaskDto.setProcess_instance_initiator(dto.getProcess_instance_initiator());
            insertTaskDto.setProcess_instance_subject(dto.getSubject());
            insertTaskDto.setProcess_instance_initiator_id(dto.getProcess_instance_initiator_id());
            insertTaskDtos.add(insertTaskDto);
        }
        return insertTaskDtos;
    }

    @Override
    public List<UpdateTaskDto> updateTask(List<TaskDto> taskDtoList) {
        List<UpdateTaskDto> updateTaskDtos = new ArrayList<>();
        for (TaskDto dto : taskDtoList) {
            UpdateTaskDto updateTaskDto = new UpdateTaskDto();
            updateTaskDto.setTask_id(dto.getTask_id());
            updateTaskDto.setAssignments(dto.getAssignments());
            updateTaskDtos.add(updateTaskDto);
        }
        return updateTaskDtos;
    }
}
